package com.axiu.lesson11_1_4;

import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;

import java.io.File;
import java.io.IOException;

public class MainActivity extends AppCompatActivity {

    VideoView videoView;
    MediaController mediaController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        videoView = (VideoView) findViewById(R.id.video);
        mediaController = new MediaController(this);
        File video = null;
        try {
            video = new File(Environment.getExternalStorageDirectory().getCanonicalFile()+"/TSA_VIDEO.mp4");
        } catch (IOException e) {
            e.printStackTrace();
        }
        if(video.exists()){
            videoView.setVideoPath(video.getAbsolutePath());
            videoView.setMediaController(mediaController);
            mediaController.setMediaPlayer(videoView);
            //mediaController.setAnchorView(videoView);

            videoView.requestFocus();
            //mediaController.show();
        }


    }
}
